﻿using Ah.Testudin.Engine.Actors.Components;
using Ah.Testudin.Engine.Actors.Components.Render;
using Ah.Testudin.Engine.Content;
using Ah.Testudin.Engine.Events;
using Ah.Testudin.Engine.Graphics.Scenes;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Ah.Testudin.Engine.Actors.Spawning
{
    public class ExplosionActorBuilder : IActorBuilder
    {
        #region Priavate Member Variables

        private readonly ITestudinContentManager _contentManager;

        private readonly IEventManager _eventManager;

        #endregion

        #region Constructors

        public ExplosionActorBuilder(
            ITestudinContentManager contentManager,
            IEventManager eventManager)
        {
            _contentManager = contentManager;

            _eventManager = eventManager;
        }

        #endregion

        #region IActorBuilder

        public Actor BuildActor(Matrix transform)
        {
            Actor explosionActor = new Actor(
                ActorIdGenerator.GetNextActorId());

            explosionActor.SetComponent<TransformComponent>(
                new TransformComponent(
                    explosionActor,
                    transform));

            explosionActor.SetComponent<IRenderComponent>(
                new ModelRenderComponent(
                    explosionActor,
                    _contentManager.Load<Model>("Content/Models/missile"),
                    RenderPass.DynamicActor,
                    _eventManager));

            return explosionActor;
        }

        #endregion
    }
}
